local skel = fk.CreateSkill {
  name = "emo__youling",
  tags = {Skill.Switch},
}

Fk:loadTranslationTable{
  ["emo__youling"] = "游翎",
  [":emo__youling"] = "转换技：出牌阶段限一次，你可以：阳，弃置两张黑色牌，获得四张红色牌。阴：弃置两张红色牌，获得四张黑色牌。",

  [":emo__youling_yang"] = "转换技：出牌阶段限一次，你可以：<font color='#E0DB2F'>阳，弃置两张黑色牌，获得四张红色牌。</font>阴：弃置两张红色牌，获得四张黑色牌。",
  [":emo__youling_yin"] = "转换技：出牌阶段限一次，你可以：阳，弃置两张黑色牌，获得四张红色牌。<font color='#E0DB2F'>阴：弃置两张红色牌，获得四张黑色牌。</font>",

  ["#emo__youling_yang"] = "游翎：你可以弃置两张黑色牌，获得四张红色牌",
  ["#emo__youling_yin"] = "游翎：你可以弃置两张红色牌，获得四张黑色牌",
}

skel:addEffect("active", {
  card_num = 2,
  target_num = 0,
  anim_type = "switch",
  prompt = function (self, player, selected_cards, selected_targets)
    return "#emo__youling_"..player:getSwitchSkillState(self.name, false, true)
  end,
  times = function (self, player)
    return 1 - player:usedSkillTimes(self.name, Player.HistoryPhase)
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter = function (self, player, to_select, selected)
    if #selected >= 2 or player:prohibitDiscard(Fk:getCardById(to_select)) then return false end
    if player:getSwitchSkillState(self.name) == fk.SwitchYang then
      return Fk:getCardById(to_select).color == Card.Black
    else
      return Fk:getCardById(to_select).color == Card.Red
    end
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local state = Fk:getCardById(effect.cards[1]).color == Card.Black and "yang" or "yin"
    -- 换个皮肤
    if state == "yang" then
      if player.general == "moe__yunyou" then
        room:setPlayerProperty(player, "general", "moe__yunyou_")
      end
      if player.deputyGeneral == "moe__yunyou" then
        room:setPlayerProperty(player, "deputyGeneral", "moe__yunyou_")
      end
    else
      if player.general == "moe__yunyou_" then
        room:setPlayerProperty(player, "general", "moe__yunyou")
      end
      if player.deputyGeneral == "moe__yunyou_" then
        room:setPlayerProperty(player, "deputyGeneral", "moe__yunyou")
      end
    end
    room:throwCard(effect.cards, self.name, player, player)
    if player.dead then return end
    local suit = state == "yang" and "heart,diamond" or "club,spade"
    local cards = room:getCardsFromPileByRule(".|.|"..suit, 4, "allPiles")
    if #cards > 0 then
      room:obtainCard(player, cards, false, fk.ReasonPrey, player, skel.name)
    end
  end,
})

return skel
